package edu.nf.relaxenjoy.service;

import edu.nf.relaxenjoy.domain.dto.PostSearchDTO;
import edu.nf.relaxenjoy.domain.vo.PostVo;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhu
 * @date 2024-12-17
 */
public interface EsService {

    /**
     * 分页查询数据
     *
     * @param page
     * @param limit
     * @param type
     * @return
     * @throws IOException
     */
    List<PostVo> getPage(long page, long limit, Integer type) throws IOException;

    /**
     * es数据查找
     *
     * @param page
     * @param limit
     * @param postSearchDTO
     * @return
     * @throws IOException
     */
    HashMap<String, Object> esSearch(long page, long limit, PostSearchDTO postSearchDTO) throws IOException;

    /**
     * 新增一条数据
     *
     * @param postSearchVo
     * @throws IOException
     */
    void addData(PostVo postSearchVo) throws IOException;

    /**
     * 批量增加数据
     *
     * @param dataList
     * @throws IOException
     */
    @RequestMapping("addBulkData")
    void addbulkData(List<PostVo> dataList) throws IOException;

    /**
     * 删除索引中的一条数据
     *
     * @param id
     * @throws IOException
     */
    void delData(String id) throws IOException;

    /**
     * 修改数据
     *
     * @param postSearchVo
     * @throws IOException
     */
    void update(PostVo postSearchVo) throws IOException;

    /**
     * 查询所有数据
     *
     * @return
     * @throws IOException
     */
    List<PostVo> esSearchList() throws IOException;

    /**
     * 增加搜索记录
     *
     * @param keyword
     * @throws IOException
     */
    void addSearchRecordData(String keyword) throws IOException;


    /**
     * 搜索记录
     *
     * @param keyword
     * @return
     * @throws IOException
     */
    List<Map<String, Object>> esSearchRecord(String keyword) throws IOException;
}
